package Year22_Month05.day29_2;

import java.awt.*;

public enum ColorEnum {
    RED("红色",0),GREEN("绿色",1),BLUE("蓝色",2);
    ColorEnum(String color,int index){

    }


    public static void main2(String[] args) {
        ColorEnum[] colors = ColorEnum.values();
        for (int i = 0; i < colors.length; i++) {
            System.out.println(colors[i] + " " + colors[i].ordinal());
        }

        ColorEnum color1 = ColorEnum.valueOf("GREEN");
        System.out.println(color1);
//      ColorEnum color2 = ColorEnum.valueOf("YELLOW");
//      System.out.println(color1);

        ColorEnum color3 = RED;

        ColorEnum color4 = ColorEnum.RED;
    }

    public static void main1(String[] args) {
        System.out.println(RED);

        ColorEnum color = GREEN;
        switch (color){
            case RED:
                System.out.println("红色");
                break;
            case GREEN:
                System.out.println("绿色");
                break;
            case BLUE:
                System.out.println("蓝色");
                break;
            default:
                System.out.println("未知颜色");
        }
    }
}
